package com.accenture.adf.newcodington.module6.activity;

/**
 * 
 * CodingtonEventPass is about buying an entry pass which can be used to attend various 
 * events happening in New Codington
 * 
 * Topic: Activity to implement logic for checking evening pass or regular pass
 * 
 * Instructions:
 * 1. Use 'CodingtonEventPass_TryIt' as the starting point and add the following changes
 * 2. Change class name to 'CodingtonEventPass_Activity1' and save file as 'CodingtonEventPass_Activity1'
 * 3. Modify If / Else in checkIfEveningPass() method as below
 * 		a. Modify signature of checkIfEveningPass() method to additionally receive a double parameter
 * 		b. Pass total fare calculated in main() method as a parameter to checkIfEveningPass() method
 * 		c. Declare a float variable for evening additional charge as percentage inside checkIfEveningPass() method
 * 		d. Initialize the evening additional charge as 5
 * 		e. Modify If condition to apply evening additional charge on the total fare received 
 *         as parameter (total fare = total fare * (1 + evening additional charge / 100))
 * 		f. Modify else condition to print "Regular pass incurs no extra charge" to console
 * 		g. Return total fare from checkIfEveningPass() method
 * 4. Change the return type of checkIfEveningPass() to double
 * 5. Capture the return value of total fare from checkIfEveningPass() method and print to console with a message as 'Total fare after checking for evening pass'
 * 
 */


public class CodingtonEventPass_Activity1 {
	
	private static final float CHILDREN_FARE = 5; //Try with different values
	private static final float ADULTS_FARE = 8; //Try with different values
	
	public static void main(String[] args){
		
		int noOfChildren;
		int noOfAdults;
		double totalChildrenFare;
		double totalAdultsFare;
		double totalFare;
		
		boolean eveningPass;
		short passValidity;
		String result;
		
		noOfChildren = 2; //Try with different values
		noOfAdults = 2;	//Try with different values
				
		totalChildrenFare = noOfChildren * CHILDREN_FARE;
		totalAdultsFare = noOfAdults * ADULTS_FARE;
		
		System.out.println("Hello New Codington Visitors!");
		System.out.println("Total Children Fare: " + totalChildrenFare);
		System.out.println("Total Adults Fare: " + totalAdultsFare);
		
		totalFare = (noOfChildren * CHILDREN_FARE) + (noOfAdults * ADULTS_FARE);
						
		System.out.println("Base Fare:"+totalFare);
		
		eveningPass = true; //Try changing values true or false
		passValidity = 1; //Try changing values between 1, 3 or 5
		
		totalFare = checkIfEveningPass(eveningPass, totalFare);
		System.out.println("Total Fare after checking for evening pass: " + totalFare);
		
		result = checkPassValidity(passValidity);
		System.out.println(result);
		
		int[] travelPass = new int[noOfChildren + noOfAdults];
		
		//Populate single dimensional array
		for(int i=0;i<travelPass.length;i++){
			int passID = i + 100;
			travelPass[i] = passID;
		}
		
		//Print array values
		System.out.println();
		for(int i=0;i<travelPass.length;i++){
			System.out.println(travelPass[i]);
		}
	}
	
	/**
	 * Method checks for evening pass and regular pass and returns appropriate message to main() method
	 * @param eveningPass - flag indicates pass issued is a evening pass or regular pass
	 * @return message - based on evening or regular pass appropriate message will be returned to main() method
	 */
	public static double checkIfEveningPass(boolean eveningPass, double totalFare){		
		float eveningCharge = 5;
		
		if(eveningPass){
			totalFare = totalFare * (1 + eveningCharge / 100);
		}else{
			System.out.println("Regular pass incurs no extra charge.");
		}
		return totalFare;
	}
	
	/**
	 * Method checks for pass duration 1 day, 3 days or 5 days and returns appropriate message to main() method
	 * @param passValidity - validity could be 1 for 1 day pass, 3 for 3 day pass and 5 for 5 day pass
	 * @return - returns appropriate message to main() method based on the duration
	 */
	public static String checkPassValidity(short passValidity){		
		
		switch(passValidity){
		
			case 1: return "No discount on 1 day pass";					
			
			case 3: return "3 day pass offers 15% discount";
					
			
			case 5: return "5 day pass offers 25% discount";					
			
			default: return "Please choose only 1, 3 or 5 for valid pass duration.";		
		}
	}
}
